#pragma once
#ifndef skyPainter_h__
#define skyPainter_h__
#include "./skyAdapter.h"

#ifdef _SYMBIAN
#include "../adapter/symbian/symPainter.h"
#elif defined(_GLES_)
#include "../adapter/gles/glPainter.h"
#elif defined(_WIN_)
#include "../adapter/windows/winPainter.h"
#endif

namespace Sky
{
class Pict;
class Font;
class Canvas;
	class Layout
	{
	public:
		enum Align
		{
			left,
			right,
			middle,
			top,
			bottom,
			center
		};
	};


	
	class Painter : public OSPainter
	{
		DECL_RTTI1(Painter,OSPainter);
	public:
		Painter(void);
		~Painter(void);;
	public:
		Bool	init(myResMgr* mgr){return vTrue;};
		Void	unInit(){}
		Bool	attachPict(Pict* pict);
		Pict* 	detachPict();

		Bool	attachFont(Font* font);
		Font* 	detachFont();

		Bool	attachCanvas(Canvas* canvas);
		Canvas* detachCanvas();

		Bool begin();
		Void end();

		Void drawLine(Point& start,Point& end) ;
		Void drawRect(Rect& rect);
		Void drawRect(Rect& rect,Color color);

		Void fillRect(Rect& rect);
		Void fillRect(Rect& rect,Color color);
		Void blendRect(Rect& rect,Color color);
		Void setPenColor(Color color);
		Void setBrushColor(Color color);
		Void drawPict(Rect& dstRect,Pict* pict,Rect* srcRect = vNull);
		Void drawText(Rect& dstRect,const String* text,Color color,Layout::Align align = Layout::left ) ;

		Pict* getPict(){return mpPict;};
		Font* getFont(){return mpFont;}
		Canvas* getCanvas(){return mCanvas;}
		Void  present(Pict* pct);

		virtual Size	calTextSize(String* str,Font* font = vNull);

		virtual Rect*	getClipArea();
		virtual Void	setClipArea(u32 x,u32 y,u32 w,u32 h);
		virtual Void	setClipArea(Rect* rect);

		virtual Rect*	getInvalidArea();
		virtual Void	setInvalidArea(u32 x,u32 y,u32 w,u32 h);
		virtual Void	setInvalidArea(Rect* rect);
		virtual Void	setInvalidObject(Object* object){mpObject = object;}

		Bool fillWith(Pict* srcPict,Rect* srcRect,Rect* dstRect);
		Bool mirrorWith(Pict* srcPict,Pict* dst,u32 MirrorType_);

		Bool invalidate(Rect* rect){mbNeedRedraw = vTrue; mInvalidRect = *rect;return vTrue;};
		Bool isNeedRedraw(){return mbNeedRedraw;}
	private:
		Bool			mbNeedRedraw;
		Pict*			mpPict;
		Canvas*			mCanvas;
		Object*			mpObject;
		Font*			mpFont;
		Rect			mClipRect;
		Rect			mInvalidRect;
	};
	typedef RefPtr<Painter> PainterPtr;
}
#endif // skyPainter_h__
